import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { PageItemRenderer } from "../../common/renderers/PageItemRenderer";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { CrossTaskGetTaskBtn } from "../CrossTaskGetTaskBtn";
import { CrossTaskHardLevel } from "../CrossTaskHardLevel";
import { CrossTaskTaskDescData } from "../data/CrossTaskTaskDescData";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ETaskStatus } from "../../../../../Message/Game/ETaskStatus";
import { ImagesConst } from "../../../resource/ImagesConst";
import { DisplayUtil } from "../../../../common/DisplayUtil";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class CrossTaskTaskDescRender
    
    export  class CrossTaskTaskDescRender extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            this._getTaskBtn.addEventListener(flash.events.MouseEvent.CLICK, this.clickGetTaskHandler);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(0, 0, 198, 353, this);
            this._bg1 = ObjCreate.createBitmap(null, 20, 16, this);
            this._bonusList = ObjCreate.createTileList(20, 160, 173, 40, this);
            this._bonusList.rowHeight = 37;
            this._bonusList.columnWidth = 40;
            this._bonusList.mouseChildren = true;
            this._bonusList.mouseEnabled = true;
            this._bonusList.setStyle("cellRenderer", PageItemRenderer);
            ObjCreate.createGTextField(Language.getString(80464), 72, 205, 200, 20, this, null, true);
            var loc1=GlobalStyle.textFormat1;
            loc1.leading = 4;
            this._txtDesc = ObjCreate.createGTextField("", 15, 224, 175, 120, this, loc1);
            this._txtDesc.multiline = true;
            this._txtDesc.wordWrap = true;
            this._getTaskBtn = new CrossTaskGetTaskBtn();
            this._getTaskBtn.x = 28;
            this._getTaskBtn.y = 302;
            this.addChild(this._getTaskBtn);
            this._hardLevel = new CrossTaskHardLevel();
            this._hardLevel.x = 87;
            this._hardLevel.y = 69;
            this.addChild(this._hardLevel);
            this._txtExprience = ObjCreate.createGTextField("", 88, 92, 200, 20, this);
            this._txtLingQi = ObjCreate.createGTextField("", 88, 117, 200, 20, this);
            this._txtTaskName = ObjCreate.createGTextField("", 109, 34, 200, 20, this);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            this._myData = arg1 as CrossTaskTaskDescData;
            this._txtTaskName.htmlText = this._myData.taskName;
            this._bonusList.dataProvider = this._myData.bonus;
            this._bonusList.drawNow();
            this._hardLevel.lightStarNum = this._myData.hardLevel;
            this._txtExprience.text = this._myData.experience.toString();
            this._txtLingQi.text = this._myData.lingQi.toString();
            this._txtDesc.text = this._myData.desc;
            LoaderHelp.addResCallBack(ResFileConst.crossTask, this.onResGot);
            return;
        }

        /* internal  */onResGot(): void
        {
            if (this.parent == null) 
            {
                return;
            }
            this._bg1.bitmapData = GlobalClass.getBitmapData(this._myData.bgName);
            _listData;
            if (this._myData.isBtnShow) 
            {
                this.addChild(this._getTaskBtn);
                var loc1=this._myData.status;
                switch (loc1) 
                {
                    case ETaskStatus._ETaskStatusCanGet:
                    {
                        this._getTaskBtn.update(ImagesConst.CrossTaskGetTask, true);
                        break;
                    }
                    case ETaskStatus._ETaskStatusNotCompleted:
                    {
                        this._getTaskBtn.update(ImagesConst.CrossTaskGot, false);
                        this.selected = true;
                        break;
                    }
                    case ETaskStatus._ETaskStatusHadCompleted:
                    {
                        this._getTaskBtn.update(ImagesConst.CrossTaskDone, false);
                        break;
                    }
                }
            }
            else 
            {
                DisplayUtil.removeMe(this._getTaskBtn);
            }
            return;
        }

        /* internal  */clickGetTaskHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CrossTaskGetTaskReq, this._myData));
            return;
        }

        /* internal */ /* var */_myData: CrossTaskTaskDescData;

        /* internal */ /* var */_bg1: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bonusList: GTileList;

        /* internal */ /* var */_txtDesc: GTextFiled;

        /* internal */ /* var */_getTaskBtn: CrossTaskGetTaskBtn;

        /* internal */ /* var */_hardLevel: CrossTaskHardLevel;

        /* internal */ /* var */_txtExprience: GTextFiled;

        /* internal */ /* var */_txtLingQi: GTextFiled;

        /* internal */ /* var */_txtTaskName: GTextFiled;
    }
